using System;
using System.Text;
using System.Linq;
using DevExpress.ExpressApp;
using System.ComponentModel;
using DevExpress.ExpressApp.DC;
using System.Collections.Generic;
using DevExpress.Persistent.Base;
using DevExpress.ExpressApp.Model;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.Editors;
using DevExpress.ExpressApp.Updating;
using DevExpress.ExpressApp.Model.Core;
using DevExpress.ExpressApp.Model.DomainLogics;
using DevExpress.ExpressApp.Model.NodeGenerators;
using DomainComponents.Common;
using DomainComponents.XCRM;

namespace XCRM.Module
{
    // For more typical usage scenarios, be sure to check out http://documentation.devexpress.com/#Xaf/clsDevExpressExpressAppModuleBasetopic.
    public sealed partial class XCRMModule : ModuleBase
    {
        public XCRMModule()
        {
            InitializeComponent();
        }
        public override IEnumerable<ModuleUpdater> GetModuleUpdaters(IObjectSpace objectSpace, Version versionFromDB)
        {
            ModuleUpdater updater = new DatabaseUpdate.Updater(objectSpace, versionFromDB);
            return new ModuleUpdater[] { updater };
        }
        public override void Setup(XafApplication application)
        {
            base.Setup(application);
            // Manage various aspects of the application UI and behavior at the module level.

            RegisterEntities();
        }

        public static void RegisterEntities()
        {

            XafTypesInfo.Instance.RegisterEntity("Lead", typeof(ICRMLead));
            XafTypesInfo.Instance.RegisterEntity("Role", typeof(IPersistentRole));
            XafTypesInfo.Instance.RegisterEntity("Address", typeof(IGenericAddress));
            //XafTypesInfo.Instance.RegisterEntity("Phone", typeof(IPhone)); TODO
            XafTypesInfo.Instance.RegisterEntity("ObjectAccessPermission", typeof(IObjectAccessPermission));
            XafTypesInfo.Instance.RegisterEntity("Note", typeof(INote));
            XafTypesInfo.Instance.RegisterEntity("PersistentFileData", typeof(IPersistentFileData));
            XafTypesInfo.Instance.RegisterEntity("PersistentResource", typeof(IPersistentResource));
            XafTypesInfo.Instance.RegisterEntity("DCUser", typeof(IDCUser));


            XafTypesInfo.Instance.RegisterSharedPart(typeof(INotes));
            XafTypesInfo.Instance.RegisterSharedPart(typeof(ILead));

            XafTypesInfo.Instance.RegisterSharedPart(typeof(IActivityTarget));
            XafTypesInfo.Instance.RegisterSharedPart(typeof(IPerson));
        }
    }
}
